import {
    getmycalendar,
    getTypeList,
    getmyMonthCalendar
} from '@/services/attendance/attendance';

export default {
    namespace: 'log',
    state: {
        data: {
            leave: [],
            weekend: [],
            holiday: [],
            fillsClass: [],
            exception: [],
            myOverTime: [],
            myOutTimeVos: [],
            myTripTimeVos: []
        },
        thead: [
            '月/日',
            '1',
            '2',
            '3',
            '4',
            '5',
            '6',
            '7',
            '8',
            '9',
            '10',
            '11',
            '12',
            '13',
            '14',
            '15',
            '16',
            '17',
            '18',
            '19',
            '20',
            '21',
            '22',
            '23',
            '24',
            '25',
            '26',
            '27',
            '28',
            '29',
            '30',
            '31'
        ],
        month: [
            '1月',
            '2月',
            '3月',
            '4月',
            '5月',
            '6月',
            '7月',
            '8月',
            '9月',
            '10月',
            '11月',
            '12月'
        ],
        // today: {
        //     leave: [],
        //     exception: [],
        //     myOverTime: [],
        //     myOutTimeVos: [],
        //     myTripTimeVos: [],
        //     holiday: []
        // },
        typelist: {
            exceptionType: [],
            leaveTypeVos: [],
            outtripType: []
        }
    },
    effects: {
        // *fetchTypeList({ payload }, { put, call }) {
        *fetchTypeList(_, { put, call }) {
            const result = yield call(getTypeList);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        typeList: result.data
                    }
                });
            }
        },
        *fetchMycalendar({ payload }, { put, call }) {
            const result = yield call(getmycalendar, payload.parameter);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        data: result.data
                    }
                });
            }
        },
        *fetchMyMonthCalendar({ payload }, { put, call }) {
            const result = yield call(getmyMonthCalendar, payload.parameter);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        data: result.data
                    }
                });
            }
        }
        // *fetchMycalendarToDay({ payload, callback }, { put, call }) {
        //     const result = yield call(getmycalendar, payload.parameter);
        //     if (result && result.code === 10000) {
        //         callback();
        //         yield put({
        //             type: 'save',
        //             payload: {
        //                 today: result.data
        //             }
        //         });
        //     }
        // }
    },
    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
